/**
 * 
 */
package org.totalbeginner.tutorial;

import static org.junit.Assert.*;

import org.junit.Test;

/**
 * @author Ibraheem.Abdullah
 *
 */
public class BookTest {

	@Test
	public void testBook() {
		Book b1 = new Book("Peace and War");
		assertEquals("Peace and War", b1.getTitle());
		assertEquals("Unknown Author", b1.getAuthor());
	}
	
	@Test
	public void testBook2() {
		Book b1 = new Book("Peace and War","Ibraheem");
		assertEquals("Peace and War", b1.getTitle());
		assertEquals("Ibraheem", b1.getAuthor());
	}
	
	@Test
	public void testSetPerson() {
		Book b1 = new Book("Peace and War");
		Person p1 = new Person();
		p1.setName("Loaner Name");
		b1.setPerson(p1);
		assertEquals("Loaner Name", b1.getPerson().getName());
	}
	
	@Test
	public void testToString(){
		Book b1 = new Book("Peace and War");
		b1.setAuthor("Tony Graig");
		Book b2 = new Book("Test Book");
		b2.setAuthor("Noman");
		Person p1 = new Person();
		p1.setName("Ibraheem");
		Person p2 = new Person();
		p2.setName("Ibraheem.Abdullahsh");
		
		String exp1 = "Peace and War by Tony Graig is available";
		assertEquals(exp1, b1.toString());
		MyLibrary m1 = new MyLibrary("Test");
		m1.checkout(b1, p1);
		String exp2 = "Peace and War by Tony Graig is checked out by Ibraheem";
		assertEquals(exp2, b1.toString());
		
		String exp3 = "Test Book by Noman is available";
		assertEquals(exp3, b2.toString());
		m1.checkout(b2, p2);
		String exp4 = "Test Book by Noman is checked out by Ibraheem.Abdullahsh";
		assertEquals(exp4, b2.toString());
		
	}
}
